package com.automation.autocode.mappers;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.automation.autocode.model.User;

@Mapper
public interface UserMapper {
	// mybatis中数据库不能自动识别大写字母，如userName，它只认识user_name，因此需要转换
	// @Results({ @Result(column = "uname", property = "userName") })
	@Select("SELECT * FROM AUSER")
	List<User> findAll();

	@Insert("INSERT INTO AUSER(uname,password,authority,phone) VALUES (#{uname},#{password},#{authority},#{phone})")
	void addOne(User user);

	@Update("UPDATE AUSER SET uname=#{uname},password=#{password},authority=#{authority},phone=#{phone} where uid=#{uid}")
	void update(User user);

	@Select("SELECT * FROM auser WHERE uid=#{uid}")
	User findOne(int id);

	@Delete("DELETE FROM AUSER WHERE uid=#{uid}")
	void delOne(int id);
}
